package com.jiawa.train.batch.job;

import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Component;

//适合单体应用，不适合集群
//因为多个节点只需要一个节点跑，多个任务跑会造成重复，可以增加分布式锁，解决集群问题
//没法实时更改定时任务和状态
@Component
@EnableScheduling
@DisallowConcurrentExecution
public class QuartzTestJob implements Job {
	@Override
	public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
		System.out.println("QuartzTestJob Strat！");
//		try {
//			Thread.sleep(1000);
//		} catch (InterruptedException e) {
//			throw new RuntimeException(e);
//		}
		System.out.println("QuartzTestJob End！");
	}
 }
